package com.cskaoyan.javase.oop2._2polymorphic._2advantage;

/**
 * @description: instanceof的使用
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * null instanceof 任何类 结果都是false
 */
public class Demo2 {
    public static void main(String[] args) {
        Father f = new Father();
        Son s = new Son();
        Demo2 d = null;
        System.out.println(f instanceof Father); //true 检查是否是自身对象
        System.out.println(s instanceof Father); //true 检查是否是自身的子类对象
        System.out.println(d instanceof Demo2); //false null instanceof 任何类都是false
    }
}

class Father {
}

class Son extends Father {
}
